package tgc.edu.tms.service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tgc.edu.tms.custom.CommonService;
import tgc.edu.tms.entity.Classroom;
import tgc.edu.tms.entity.Jcb;
import tgc.edu.tms.entity.TbclassClassroom;
import tgc.edu.tms.repository.TbclassClassroomRepository;

@Service
public class TbclassClassroomService extends CommonService<TbclassClassroom, Integer>{
	@Autowired
	private TbclassClassroomRepository tcroomDAO;
	
	public void deleteAlls() {
		tcroomDAO.deleteAll();
	}
	/***
	 * 生成新的时间选择的表
	 * @param jcb
	 * @param classroom
	 * @return
	 */
	public void findByList(List<Jcb> jcb, List<Classroom> classroom) {
		Integer agid=1;
		Collections.shuffle(jcb);
		for (int i = 0; i < jcb.size(); i++) {
			Jcb jcb2 = jcb.get(i);
			Collections.shuffle(classroom);
			for (int j = 0; j < classroom.size(); j++) {
				Classroom classroom2 = classroom.get(j);
				TbclassClassroom tcroom=new TbclassClassroom();
				tcroom.setId(agid);
				tcroom.setClassroom(classroom2);
				tcroom.setJcb(jcb2);
				tcroomDAO.save(tcroom);
				agid=agid+1;
			}
		}
	}

}
